﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OPM.Class;
using System.Web.Helpers;

namespace OPM.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return U.IsLogin ? RedirectToAction("Index", "Timeline") : RedirectToAction("Login", "Account");
        }

        public ActionResult ChangeLanguage(string changeTo = "TH")
        {
            string sessionCulture = Session["culture"] as string;
            string cultureChanged = (sessionCulture??"th-TH").StartsWith("th") ? "en-US" : "th-TH";
            Session["culture"] = cultureChanged;
            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureChanged);
            return Content(Util.RenderTagMetaRedirect("/", "หน้าแรก", cultureChanged));
        }
    }
}
